package com.naizhuai.Model.db;


import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;

import com.naizhuai.AppContext;
import com.naizhuai.Model.db.ainote.Note;
import com.naizhuai.Model.db.ainote.NoteDao;
import com.naizhuai.Model.db.eneity.DateConverter;
import com.naizhuai.Model.db.eneity.ManageNoteBean;
import com.naizhuai.Model.db.managenote.ManageNoteDao;
import com.naizhuai.Model.db.search.SearchHistoryBean;
import com.naizhuai.Model.db.search.SearchHistoryDao;
import com.naizhuai.Model.db.user.UserDao;
import com.naizhuai.Model.db.user.PersonUserBean;

import android.content.Context;

/**
 * Created by lichenxi on 2017/5/24.
 */

@Database(entities = {Note.class, PersonUserBean.class,SearchHistoryBean.class,ManageNoteBean.class}, version = 1)
@TypeConverters(DateConverter.class)
public abstract class AppDatabase extends RoomDatabase {

    public abstract NoteDao NoteDao();
    public abstract UserDao UserDao();
    public abstract SearchHistoryDao SearchDao();
    public abstract ManageNoteDao ManageNoteDao();
    private static AppDatabase sInstance;

    public static synchronized AppDatabase getInstance() {
        if (sInstance == null) {
            sInstance = Room
                    .databaseBuilder(AppContext.getInstance(), AppDatabase.class, "naizhu.db")
                    .build();
        }
        return sInstance;
    }


}
